<template>
	<view class="" style="height: 100vh;overflow: hidden;">
		<view class=""
			style="height: 229rpx;position: relative; overflow: hidden;background: linear-gradient(180deg, #ECC581 0%, #FFFFFF 100%)">
			<view class="ml-40">
				<view class="mb-32 pt-30">
					当前积分
				</view>
				<view class="c-11 f-80">
					{{codenum}}
				</view>
			</view>
			<view class="" style="width: 360.3rpx;    margin-top: -167rpx;height: 355.43rpx;float: right;">
				<image src=" /goodsPage/static/doct/jifenbg.png" mode=""></image>
			</view>

		</view>
		<view class="bg-FFFFFF"
			style="height: 1280rpx;position: relative; border-radius: 60rpx 60rpx 0px 0px;overflow: hidden;">
			<view class="mt-30">
				<u-tabs inactive-color="#DFB982" active-color="#DFB982" :list="list" :is-scroll="false"
					:current="current" @change="change"></u-tabs>
			</view>
			<view class="" style="width: 750rpx;height: 0.1rpx;background: #DDDDDD;"> </view>
			<view class="px-28" style="height: 100%; overflow: scroll;">
				<scroll-view scroll-y="true" @scrolltolower="scrolltolower" style="height: 800rpx;">
					<view class="just-between" style="height: 158rpx;  
								border-bottom: 1rpx solid #DDDDDD;" v-for="(item,index) in dataList" :key="item.id">
						<view class="">
							<view class="mt-30 f-32 c-11 f-400">
								{{item.memo}}
							</view>
							<view class="mt-16 f-26 c-77 f-400">
								{{item.createtime | getYMDHMS}}
							</view>
						</view>
						<view class="aj-center c-DFB982 f-36 f-bold" :class="item.score>0?'c-DFB982':'c-11'">
							{{item.score}}
						</view>
					</view>
				</scroll-view>
				<!-- <scroll-view scroll-y="true" @scrolltolower="scrolltolower"   style="height: 800rpx;">
					<view class="just-between" style="height: 158rpx;    border-bottom: 1rpx solid #DDDDDD;"
						v-for="(item,index) in 10" :key="index">
						<view class="">
							<view class="mt-30 f-32 c-11 f-400">
								商品兑换
							</view>
							<view class="mt-16 f-26 c-77 f-400">
								2022-12-23 12:23
							</view>
						</view>
						<view class="aj-center c-11 f-36 f-bold">
							-2000.00
						</view>
					</view>
				</scroll-view> -->


			</view>
			<view class="aj-center mt-20" v-if="dataList.length==0">
				暂无记录
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				createtime: 1644853036103,
				token: '',
				total: '', //总条数
				page: 1,
				type: 0, //点击的顶部切换
				page: 1, //分页
				codenum: '', //可用积分
				dataList: [], //返回的参数
				list: [{
					name: '全部'
				}, {
					name: '收入'
				}, {
					name: '支出',

				}],
				current: 0
			}
		},
		onShow() {
			uni.getStorage({
				key: 'token',
				success: (res) => {
					this.token = res.data;
					console.log(res.data);
					this.useblescore();
					// 用户积分明细
					this.scorelog()

				}
			});
		},
		filters: {
			getYMDHMS(timestamp) {
				var numtimestamp = Number(timestamp);
				let time = new Date(numtimestamp)
				let year = time.getFullYear()
				let month = time.getMonth() + 1
				let date = time.getDate()
				let hours = time.getHours()
				let minute = time.getMinutes()
				let second = time.getSeconds()

				if (month < 10) {
					month = '0' + month
				}
				if (date < 10) {
					date = '0' + date
				}
				if (hours < 10) {
					hours = '0' + hours
				}
				if (minute < 10) {
					minute = '0' + minute
				}
				if (second < 10) {
					second = '0' + second
				}
				return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
			}

		},
		methods: {
			scrolltolower() {
				console.log('下拉')
				if (this.total != this.dataList.length) {
					this.$https('doctindex.scorelog', {
						token: this.token,
						type: this.type,
						page: this.page
					}).then(res => {
						console.log(res, 'codetoken')
						this.dataList.push(...res.data.data);
						// this.total=res.data.total;
					})
				} else {
					console.log('暂无数据')
				}
			},
			// 可用积分
			useblescore() {
				this.$https('doctindex.useblescore', {
					token: this.token
				}).then(res => {
					console.log(res, 'codetoken')
					this.codenum = res.data;
				})
			},
			// 用户积分明细
			scorelog() {
				this.$https('doctindex.scorelog', {
					token: this.token,
					type: this.type,
					page: this.page
				}).then(res => {
					console.log(res, 'codetoken')
					this.dataList = res.data.data;
					this.total = res.data.total;
				})
			},
			change(index) {
				this.type = index;
				this.current = index;
				this.dataList = [];
				this.page = 1;
				this.scorelog()
			}
		}
	}
</script>

<style>

</style>
